Skip to content

Feat: macOS window parity and the text context menu - #147

Closed
b-re-w wants to merge 19 commits into
developfrom
feat/macos-window-parity
Closed

b-re-w wants to merge 19 commits into
developfrom
feat/macos-window-parity

Conversation

@b-re-w

@b-re-w b-re-w commented Oct 4, 2026

Copy link
Copy Markdown
Member

Closes #146
Closes #142 (macOS paths only; the issue's Win32 and X11 parts remain open and need their own change)

Stacked on #128: this branch is based on feat/appkit-window-default, so the diff against develop includes #128 until it merges. Retarget or rebase-free merge order: merge #128 first.

Kotlin/Native window (renderer/macos)

  1. Minimum size from the Window node (contentMinSize).
  2. Dock icon from the app's icon asset, applied once the asset arrives.
  3. Dark mode follows live changes: KVO on NSApplication.effectiveAppearance updates the theme's scheme and requests a frame.
  4. NSPasteboard-backed LocalClipboard and LocalClipboardManager.

Text context menu (#142)

Compose's own ContextMenu is not used: it is AWT-bound on desktop and its native path is disabled on this platform (the flag is documented in MacosRenderer.kt). Instead one model (renderer/desktop/src/TextContextMenu.kt, symlinked into the macOS target) gives rows, labels, order and the Paste enablement. K/N builds an NSMenu from it. The GraalVM window gets the same list as a spec string (dxc_native_set_text_menu), builds the NSMenu in appkit_window.m, and reports the chosen row as a menu-command event. Both turn it into Command+X/C/V/A key presses on the focused field, so IME composition is untouched. The right-click release is now sent after the menu closes so the scene does not think the button is held.

Tests

TextContextMenuTest (JVM), MacosClipboardTest, MacosAppearanceTest, MacosWindowChromeTest (K/N), all with fakes.

b-re-w added 19 commits October 4, 2026 17:33
The native-image renderer opened the AppKit window of its own only when
DXC_APPKIT_WINDOW was set. macOS now always opens it, and the older arrangement of a
second thread for the toolkit is gone from the C entry.

The window takes what the application asks for in its first batch: title, size, minimum
size, resizable, system or transparent title bar with a unified toolbar so the traffic
lights share the bar's line, the icon, and a material behind the page. Files dropped on a
FileDropTarget reach the node under them without the toolkit, with the full path list read
outside the 96 byte event record. Pointer and accessibility coordinates are converted
between points and pixels. The smoke test's auto exit is honoured.

Covers FR-27 (file drop) and NFR-14. fr27_* tests in NativeFileDropTest and
scripts/tests/macos-window-default.test.sh. Korean IME, VoiceOver and resize feel remain
manual checks on a Mac.
… (NFR-14)

An unattended macOS runner refuses TransformProcessType, and the window can still be made
once the activation policy is set to regular. The refusal is reported instead of stopping
the renderer.
A process told it has no display is given no clipboard by Compose desktop, so copy and
paste in a text field went nowhere. The window now supplies the clipboard from its own
pasteboard. The icon is passed as premultiplied RGBA bytes so that every desktop can read
the same record.
…debounce (FR-5)

TextChanged was held back 120 ms after the last keystroke and restarted by every key, so a
line echoing the typed text trailed the key by the pause plus a frame or two, and by the
whole burst when typing was fast. Measured on the AppKit window with real key events posted
to it: 152 ms from key to the echo being on screen, and the Host heard nothing during a burst.

The first edit after a quiet period is now sent immediately, later ones are collapsed to at
most one per interval carrying the latest text, and the last one is always sent. Covers the
FR-5 criterion that the Host is notified of edits through a debounced TextChanged: bursts
still collapse. Adds a test that a request for a frame is served by the next turn of the loop.
… not stretched (NFR-14)

AppKit stays in its own tracking loop while an edge is dragged and only calls the view back,
so the renderer's frame loop did not run: the layer's drawable size changed and the last
frame was shown scaled to it. Measured with a scripted resize of 120 sizes: 0 frames
presented and 120 sizes shown stretched.

setFrameSize now sets the drawable size and asks the renderer for a frame at that size through
the draw callback the Windows window already uses, a live resize presents with the window's
transaction, and the layer anchors a stale drawable to its corner instead of scaling it. Same
scripted resize after: 120 presented, 0 stale, 0 stretched, 6.1 ms per size on average.

Also adds the aids used to measure it: DXC_REPORT_LATENCY timestamps from key to pixels,
DXC_REPORT_RESIZE counts, DXC_SYNTH=type,keys,resize to drive the window from inside, and
DXC_LEGACY_RESIZE to see the old behaviour. The counting is in appkit_resize.h and is
tested without a window by scripts/tests/appkit-live-resize.test.sh.
… 120 ms throttle (FR-5)

Typing in a field was held back by a 120 ms interval between notifications. An edit is now
told to the Host on the next frame, carrying the text the field holds then, so keys inside
one frame are one event and the last text is always sent. No measured reason for 120 ms
was recorded anywhere in the repository.
…ves to the fork

Restores the macOS arm64, Linux x64 and Linux arm64 native-image build and smoke jobs that #113 removed, in their own path-filtered workflow. Windows stays in test-native-renderer.yml.
Resuming from withFrameNanos goes back through the scene's dispatcher, so the send and the
recomposition after it each cost a frame. Sent in the callback, the Host's batch is applied
before the same frame is composed. Measured on macOS: key to on-screen echo 26 ms to 12.7 ms.
… context menu (FR-5, FR-19, FR-33.6)

Minimum size, Dock icon, live dark mode and an NSPasteboard clipboard for the
Kotlin/Native window (#146). The right-click text menu (#142) is built from one
shared model on both macOS paths: an NSMenu from Kotlin on Kotlin/Native, and
appkit_window.m described by the same list on the GraalVM window, reporting the
chosen item as an event that is turned into the shortcut key presses.
…FR-14.4, FR-19)

Minimum size rule, Dock icon timing, system dark monitor and the pasteboard text rules
now live in WindowParity.kt, used by the GraalVM and the Kotlin/Native windows. Each
keeps only its AppKit calls. The GraalVM window also follows the monitor instead of its
own polling state, and its clipboard uses the shared rules.
b-re-w added a commit that referenced this pull request Oct 4, 2026
… over the parity harness

Stacked on #165. The window code is the fork's now; the Compose half of what #147 and #155 added
is not, and was on neither develop nor #165.

- macOS Kotlin/Native: contentMinimum, DockIcon (with ImageBitmap.toNSImage), SystemDarkMonitor
  fed by the appearance notification, and the fork's MacosClipboard and MacosClipboardManager,
  so Paste is offered by what the pasteboard holds.
- GraalVM macOS: the same DockIcon, contentMinimum and a polled SystemDarkMonitor, the
  clipboard through TextPasteboard, window options read once by NativeWindowOptions, and the
  synthetic exit.
- The K/N-portable LatencyTrace and SyntheticInput (no String.format, System.nanoTime shim,
  exit after the resize), the JvmCompatShims they need, and ParityMeasurementTest.
- The hand-check app and its consumer fixture changes.

Not here, with reasons: NativeWindowShell, the Win32 letter and digit keys and the default
window switches depend on #134 (beginNativeWindowDrag, win32ComposeKey, the X11 and Win32
defaults, also #160, #170, #172) and come with it. The GraalVM text menu needs the fork's
setTextMenu, which is not in the pinned fork commit yet. The resize header counter on
Kotlin/Native is dropped: the fork's FramePresentLog replaces it.

Covers FR-33.6 (clipboard and text menu enablement), FR-19 (min size, Dock icon), NFR-14.
@b-re-w

b-re-w commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Closing: the macOS work in this PR is in the Compose fork's window modules, reworked, at the commit develop pins (WINDOW_REVISION 2280a6d9 in renderer/scripts/build-compose.sh):

  • contentMinSize, dock icon, live dark mode, NSPasteboard clipboard and the NSMenu text menu: extended/window/graalvm/graalvm-macos appkit_window.m (lines 1152, 1320, 1523, 250-274, and 538 dxc_native_set_text_menu), and extended/window/native/macos MacosWindow.kt:678, MacosAppearance.kt, MacosClipboard, TextContextMenu.
  • The right-click text menu on the GraalVM macOS window landed as fork Elliptical radial gradients (FR-23) #93, wired in compose-rust Feat: Wire fork window size hints, keep one macOS right-click menu #203; the owner's hardware check passed Paste and the menu position on both paths.

Left only here: three-line dxc_native_set_text_menu stubs for Win32 and X11 and WindowEvents.MENU_COMMAND. Develop shows the OS menu on Win32 through NativeContextMenu.kt (dxc_native_context_menu), and the Win32/X11 parts of #142 stay tracked there. The branch is kept.

@b-re-w b-re-w closed this Oct 17, 2026
@b-re-w
b-re-w deleted the feat/macos-window-parity branch November 12, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant